/*----------------------------------------------------------------------------
 * News Ticker
 * ---------------------------------------------------------------------------
 * Date      : 2011-10-05
 * Author    : naiyumie
 * ---------------------------------------------------------------------------
 * USAGE
 * ---------------------------------------------------------------------------
 * $(selector).TopMenu();
 * ---------------------------------------------------------------------------
 * EXAMPLE
 * ---------------------------------------------------------------------------
 *
 *----------------------------------------------------------------------------
 */
$.fn.NewsTicker	= function (option)
{
	option = option || {};
	var element		= $(this);
	var interval	= null;
	var current		= 0;
	var target		= 'ul.issue';
	var delay		= option.delay ? option.delay : 3000;
	var size		= parseInt($(this).find(target).size());

	$(this).find(target).each(function(i)
	{
		if (i>0) { $(this).hide(); }

		$(this).hover
		(
			function() { clearInterval(interval); },
			function() { interval	= setInterval(rotate, delay); }
		);

	});

	var rotate	= function ()
	{
		current++;

		if (current>=size) { current = 0; }

		$(element).find(target).hide();
		$(element).find(target).eq(current).show();
	};

	interval	= setInterval(rotate, delay);
};